//
//  UIView+IBExtension.swift
//  WeiBo14
//
//  Created by HM on 16/3/2.
//  Copyright © 2016年 HM. All rights reserved.
//

import UIKit



extension UIView {
    
    // 边线宽度
    @IBInspectable var borderWidth: CGFloat {
        get{
            return layer.borderWidth
        }
        set{
            layer.borderWidth = newValue
        }
    }
    
    // 边线颜色
    @IBInspectable var borderColor: UIColor? {
        get{
            guard let color = layer.borderColor else {
                return nil
            }
            return UIColor(CGColor: color)
        }
        
        set{
            layer.borderColor = newValue?.CGColor
        }
    }
    
    @IBInspectable var cornerRadius: CGFloat {
        get{
            return layer.cornerRadius
        }
        set{
            layer.cornerRadius = newValue
            layer.masksToBounds = newValue > 0
        }
    }
}
